<template>
  <div class="recommend">
    <div class="title">热销推荐</div>
    <ul>
      <li class="item border-bottom" v-for="item of list" :key="item.id">
        <div class="item-img">
          <img :src="item.imgUrl" alt="img">
        </div>
        <div class="item-info">
          <div class="info-title">{{item.title}}</div>
          <div class="info-desc">{{item.desc}}</div>
          <button class="info-btn">查看详情</button>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'HomeRecommend',
  props: {
    list: Array
  }
}
</script>

<style lang="stylus" scoped>
@import '~styles/mixins.styl';
.recommend {
  margin-top: 0.1rem;
  .title {
    padding: 0.2rem;
    color: #333;
    background-color: #f1f1f1;
  }
  .item {
    display: flex;
    padding: 0.1rem;
    .item-img {
      img {
        width: 2rem;
        height: 1.8rem;
      }
    }
    .item-info {
      flex: 1;
      padding: 0 0.2rem;
      // 给父元素添加这行属性即可
      min-width: 0;
      .info-title {
        line-height: 0.44rem;
        font-size: 0.32rem;
        // flex布局中，注意使用单行省略会与flex:1冲突
        ellipsis();
      }
      .info-desc {
        line-height: 0.44rem;
        // flex布局中，注意使用单行省略会与flex:1冲突
        ellipsis();
      }
      .info-btn {
        margin-top: 0.2rem;
        padding: 0 0.1rem;
        color: #fff;
        background-color: orange;
        font-size: 0.28rem;
      }
    }
  }
}
</style>
